package string_;

/**
 * Created with IntelliJ IDEA.
 * ClassName: StringDemo
 * Package: string_
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-29
 * Time: 19:38
 */

public class StringDemo {

    public static void main(String[] args) {
        //String的不可变性
        String s1 = "hello";
        String s2 = "hello";

        s2 = "hi";
        System.out.println(s1); //hello

    }

    public static void main1(String[] args) {

        //String 比较特别 对象 不是应该new的吗 但是可以直接赋值
        String s1 = "hello"; //放在字符串常量池
        String s2 = "hello";
        //常量池 不允许放两个相同的字符串常量
        System.out.println(s1 == s2);

    }
}
